// 公共头部
import myHeader from "/pages/headerfoot/pages/header.vue";
//公共底部
import Tabbar from '/pages/headerfoot/pages/hitgamefooter.vue'
//表格
import uninotable from "/uni_modules/uni-table/components/uni-table/uni-table.vue";
//打帮赛方法
import hitmatchcommon from '@/common/hitmatchcommon.js';
//关联选择
import unidatapicker from "/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.vue";
//cache缓存
import Cache from '@/utils/cache.js';

export default {
	components: {
		myHeader,
		Tabbar,
		uninotable,
		unidatapicker
	},
    data() {
      return {
        items: [],
		makeinfo:[],//当前赛事
		make_id:'',//赛事ID
		selectvalue:'',//选择值
		mylist:[],//我的列表
		userlist:[],//用户列表
		page:1,//页数
		makeUserCount:[],//参赛个数
      }
    },
	onLoad(options = '') {
		var that = this;
		if (options.id) {
			that.make_id = options.id;
		}
		that.getMake();
		that.getMakeRanking(); //获取赛事排行
		that.getSeasonAndMakeList(); //得到项目列表
	},
	//底部加载
	onReachBottom(){
		var that=this;
		that.page=that.page+1;
		that.getMakeRanking();//获取赛事排行
	},
	methods: {
		//获取赛事
		async getMake(id) {
			var that = this;
			var data = {};
			data['make_id']=that.make_id;
			data['make_user_id']=Cache.get('user_id');
			hitmatchcommon.getMakeLibMethod(data).then(res => {
				if (res) {
					that.makeinfo = res; //赛季列表
					that.selectvalue=res.nake_name;//赛事名称
				}
			});
		},
		//得到项目列表1
		async getSeasonAndMakeList(id) {
			var that = this;
			var data = {};
			hitmatchcommon.getSeasonAndMakeListLibMethod(data).then(res => {
				if (res) {
					that.items = res; //得到项目列表
				}
			});
		},
		//获取赛事排行
		async getMakeRanking() {
			var that = this;
			var data = {};
			data['make_id']=that.make_id;
			data['page']=that.page;
			data['make_user_id']=Cache.get('user_id');
			hitmatchcommon.getMakeRankingLibMethod(data).then(res => {
				if (res) {
					   that.mylist =res.makeUser;//我的列表
					   that.makeUserCount =String(res.makeUserCount).split('');//参赛个数
					   that.userlist = that.userlist.concat(res.makeUserList);//用户列表
				}
			});
		},
		onchange(e) {
			var that=this;
			that.page=1;//第一页
			if(e.detail.value[1]['value']){
				that.make_id=e.detail.value[1]['value'];
				
				that.selectvalue=e.detail.value[1]['text'];
				 that.userlist =[];//用户列表赋值为空
				that.getMakeRanking();//获取赛事排行
			}
		},
		onnodeclick(node) {}
	},


}